package cn.sdormitory.knowledgebase.dao;

import cn.sdormitory.knowledgebase.vo.RuleRegulationVo;
import cn.sdormitory.knowledgebase.dto.RuleRegulationDto;
import cn.sdormitory.knowledgebase.pojo.RuleRegulation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface RuleRegulationDao extends BaseMapper<RuleRegulation> {
    IPage<RuleRegulationVo> getRuleRegulationList(RuleRegulationDto regulationDto);//根据条件获取规章制度列表
    Integer addRuleRegulation(RuleRegulationDto regulationDto); //增加规章制度
    Integer updateRuleRegulation(RuleRegulationDto regulationDto);//修改规章制度
    Integer deleteRuleRegulation(Integer id);//删除规章制度

    RuleRegulation getRuleRegulationById(Integer id);

    List<RuleRegulationVo> getList();

    /**
     * 增加浏览量
     */
    @Update("UPDATE rule_regulation SET view_count = COALESCE(view_count, 0) + 1 WHERE id = #{id}")
    Integer incrementViewCount(@Param("id") Integer id);

    Integer getViewCount(Integer id);

    /**
     * 批量删除
     */
        Integer deleteList(Integer[] rIds);
}
